/*
    This is a set of libraries to assist in OpenGl and Other Applications
    Copyright (C) 2008  The Modular Engine Team

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

/// \file networkData.h
/// \brief A test file containing information that will be Developer-given
/// such as IP addresses, ports, packet lengths, Packet Message Identifiers, etc.


#ifndef NETWORKDATA_H
#define NETWORKDATA_H
#if defined(_WIN32)
#undef _WINSOCKAPI_
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#include <process.h>
#elif defined(UNIX)
#include <sys/socket.h>
#endif

namespace ModularEngine
{

	#define PACKET_BUFFER_LENGTH 512
	#define DEFAULT_PORT "9876"

	/// The Generic Message list.
	
	/// This contains the Generic Messages (GM) to be sent and recieved
	/// by the server and client.  Network Messsages, that is.
	enum GenericMessages
	{
		GM_MSG_BEGIN,
		GM_MSG_END,
		GM_CHAT,
		GM_VERSIONCHECK,
		GM_FILE,
		GM_FILECHECK,
//		GM_SERVERMESSAGE,
		GM_NEWUSER,
		GM_WBSTART,
		GM_WBPOINT,
		GM_WBEND,
		GM_LOSTUSER
	};

	/// The simple packet class that is sent/recieved by clients/servers
	class NetworkMessage
	{
	public:
		/// Type of Message 
		int nMsgType;
		/// Client Message Number
		int nMsgNumber; 
		/// Buffer containing the message
		char cBuffer[PACKET_BUFFER_LENGTH];
		/// Original User Sender
		int nUser; 
		/// Size of the message sent.

		/// This is not sent over the network, but used as an
		/// intermediary value for ease of access.
		int nSize;	

	};

	/// The functor corresponding with the function to process Network Messages
	class NetworkMessageProcFunctor
	{
	public:
		/// The Function that processes messages.
		virtual void operator () ( NetworkMessage msg ) = 0;
	};

};

#endif